package com.blvtphan.tipocketclubs.adapter;

import java.util.List;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;

import com.blvtphan.tipocketclubs.R;
import com.blvtphan.tipocketclubs.custom.CustomTextView;
import com.blvtphan.tipocketclubs.model.TrackerDetailModel;

public class TrackerDetailAdapter extends BaseAdapter{

	private List<TrackerDetailModel> lstTrackerDetail;
	private Context mContext;
	
	public TrackerDetailAdapter(Context context, List<TrackerDetailModel> lstTrackerDetail) {
		this.mContext = context;
		this.lstTrackerDetail = lstTrackerDetail;
	}
	
	@Override
	public int getCount() {
		// TODO Auto-generated method stub
		return lstTrackerDetail.size();
	}

	@Override
	public Object getItem(int arg0) {
		// TODO Auto-generated method stub
		return lstTrackerDetail.get(arg0);
	}

	@Override
	public long getItemId(int arg0) {
		// TODO Auto-generated method stub
		return arg0;
	}

	@Override
	public View getView(int pos, View v, ViewGroup parent) {
		// TODO Auto-generated method stub
		LayoutInflater inflater = (LayoutInflater) mContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE);

		View rowView = inflater.inflate(R.layout.item_tracker_detail, parent, false);
		
		CustomTextView tvPlaceName = (CustomTextView)rowView.findViewById(R.id.txt_tracker_place_name);
		CustomTextView tvPlaceCategory = (CustomTextView)rowView.findViewById(R.id.txt_tracker_place_category);
		CustomTextView tvPlaceVisitDate = (CustomTextView)rowView.findViewById(R.id.txt_tracker_place_visit_date);
		CustomTextView tvPlaceSpent = (CustomTextView)rowView.findViewById(R.id.txt_tracker_place_spent);
		CustomTextView tvPlaceSaved = (CustomTextView)rowView.findViewById(R.id.txt_tracker_place_saved);
		
		if(lstTrackerDetail!=null || lstTrackerDetail.size()>0) {
			tvPlaceName.setText(lstTrackerDetail.get(pos).getPlaceName());
			tvPlaceCategory.setText(lstTrackerDetail.get(pos).getPlaceCategory());
			tvPlaceVisitDate.setText(lstTrackerDetail.get(pos).getVisitDate());
			tvPlaceSaved.setText(lstTrackerDetail.get(pos).getSaved());
			tvPlaceSpent.setText(lstTrackerDetail.get(pos).getSpent());
		}
		
		return rowView;
	}

}
